package com.xqsigth.common.core.utils;

import org.springframework.beans.BeanUtils;

/**
 * 〈一句话功能简述〉<br>
 * 〈功能详细描述〉
 *
 * @author ganggang.wang
 * @see [相关类/方法]（可选）
 * @since 2020/5/9
 */
public class BeanConvertUtils {

    public static final <Target> Target copyProperties(Object source, Class<Target> targetClass) {
        try {
            if (source == null || targetClass == null) {
                return null;
            }
            Target doInstance = targetClass.newInstance();
            BeanUtils.copyProperties(source, doInstance);
            return doInstance;
        } catch (InstantiationException | IllegalAccessException e) {
            e.printStackTrace();
        }
        return null;
    }
}
